package view;

import controller.BlogController;
import java.util.Scanner;

public class AdminView {
    private BlogController blogController;

    public void setBlogController(BlogController blogController) {
        this.blogController = blogController;
    }

    Scanner scanner = new Scanner(System.in);

    public void showAdminView() {
        while (true) {
            System.out.println("=== 管理员主页 ===");
            System.out.println("举报记录：");
            blogController.showReports();

            System.out.println("输入要审核的博文ID: ");
            int blogId = scanner.nextInt();
            scanner.nextLine();

            System.out.println("1. 查看博文");
            System.out.println("2. 删除违规文章");
            System.out.println("3. 取消/封禁违规用户");
            System.out.println("4. 返回");
            System.out.println("请输入选择: ");

            int choice = scanner.nextInt();
            scanner.nextLine();

            switch (choice) {
                case 1:
                    blogController.showBlogDetails(blogController.getBlogById(blogId));
                    break;
                case 2:
                    blogController.deleteBlog(blogId);
                    blogController.updateReport(blogId);
                    break;
                case 3:
                    System.out.println("请输入用户ID: ");
                    int userId = scanner.nextInt();
                    scanner.nextLine();
                    blogController.banUsers(userId);
                    blogController.updateReport(blogId);
                    break;
                case 4:
                    return;
                default:
                    System.out.println("无效操作，请重新输入！！");
                    break;
            }
        }
    }
}
